package es.mgil.soaTest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import es.mgil.soaTest.R;
import es.mgil.soaTest.utils.RestProgressTask;
import es.mgil.soaTest.utils.Tweet;

public class RestMainActivity extends Activity implements OnClickListener {
	public static Tweet[] tweets;

	private Button boton;
	private EditText et_user;
	private EditText et_count;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.rest_main_layout);
		this.boton = (Button) findViewById(R.id.button1);
		this.et_user = (EditText) findViewById(R.id.usernameText);
		this.et_count = (EditText) findViewById(R.id.countText);

		this.boton.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case (R.id.button1):
			String str_url = "https://api.twitter.com/1/statuses/user_timeline.json?include_rts=true&screen_name="
					+ this.et_user.getText().toString()
					+ "&count="
					+ this.et_count.getText().toString();
			new RestProgressTask(this, str_url, this.et_user.getText().toString())
					.execute();
			break;
		}
	}
}
